﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Thaire.Investment.Domains.Transaction;

namespace Thaire.Investment.Repository
{
  public  class UnitTrustNavRepo  : BaseRepository <UnitTrustNav, int>
    {
       public UnitTrustNavRepo(ISession session)
            : base(session)
        {
        }

       public UnitTrustNav GetLastNavByHeaderID(int headerID)
       {
           var data =  _session.QueryOver<UnitTrustNav>()
               .Where(x => x.UnitTrustHeaderID == headerID)
               .OrderBy(x => x.ID).Desc.List().FirstOrDefault();
           return data;
       }
       public List<UnitTrustNav> GetListByHeaderID(int headerID)
       {
           return new List<UnitTrustNav>(_session.QueryOver<UnitTrustNav>()
               .Where(x => x.UnitTrustHeaderID == headerID)
               .OrderBy(x => x.Date).Asc.List());
       }
    }

}
